home *** CD-ROM | disk | FTP | other *** search
-
- main()
- {
- int i = 0XFFFF;
- double d = 123456789.123456789;
- char c;
-
- /* This is okay, cast does nothing */
- (char) c = 'A';
-
- printf("\n I is %x", i);
-
- (char) i = 'A';
-
- printf("\n I is %x", i);
-
- *(&(char)i + 1) = 'B';
-
- printf("\n I is %x", i);
-
- /* Show it the "right" way */
- i = 0XFFFF;
-
- printf("\n I is %x", i);
-
- *((char *) &i + 1) = 'B';
-
- printf("\n I is %x", i);
-
- /* Now try it with a double */
-
- printf("\n d is %lf", d);
-
- (int) d = 'C';
-
- printf("\n d is %lf", d);
-
- /* This causes a compiler error -- */
- /* This was removed so that the listing could be
- produced */
-
- (double) i = 'A';
-
-
- }
-
- Results:
-
- I is ffff
- I is ff41
- I is 4241
- I is ffff
- I is 42ff
- d is 123456789.123457
- d is 123456789.123048
-
-